#include <iostream>
#include <stdio.h>
#include "control.h"
#include "bank.cc"
#include "DRAM.cc"
#include "std.cc"

using namespace std;

/* Push the bus2 lines into a bus2 struct */
int fscanfbus2(struct bus2_t * line){
    return fscanf(stdin, "BUS2 %c %i %x %i %i\n",
        &line->type,
        &line->size,
        &line->address,
        &line->rcount,
        &line->icount);
}

//Updates the cache with the number of regisers accessed and the number of
//instructions. Also, the number of misses is updated
void memory::process(struct bus2_t * line){
    cache += (line->rcount + line->icount-1);
    misses++;

}

//Calls the different memorytypes for testing
int main(){

    struct bus2_t line;
    bank* bankmem4 = new bank(4);
    bank* bankmem8 = new bank(8);
    DRAM* DRAMmem64 = new DRAM(64, 3);
    DRAM* DRAMmem1024 = new DRAM(1024, 2);
    standard* stdmem = new standard();

    while(fscanfbus2(&line) != EOF){

        bankmem4->mem(&line);
        bankmem8->mem(&line);
        stdmem->mem(&line);
        DRAMmem64->mem(&line);
        DRAMmem1024->mem(&line);

    }

    stdmem->wrapup();
    bankmem4->wrapup();
    bankmem8->wrapup();
    DRAMmem64->wrapup();
    DRAMmem1024->wrapup();
}
